package com.jprocms.module.cms.controller.portal.api;

import com.jpro.framework.common.pojo.CommonResult;
import com.jpro.framework.common.pojo.PageResult;
import com.jpro.module.system.api.notice.NoticeApi;
import com.jpro.module.system.api.notice.dto.NoticePageReqDTO;
import com.jpro.module.system.api.notice.dto.NoticeRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

import static com.jprocms.module.cms.constant.CmsSysConstants.FRONT_API;

@Tag(name = "前台 -  通知公告")
@RestController
@RequestMapping(FRONT_API+"/notice")
@Validated
public class NoticeApiController {

    @Resource
    private NoticeApi noticeApi;

    @GetMapping("/page")
    @Operation(summary = "获取通知公告分页列表")
    public CommonResult<PageResult<NoticeRespDTO>> getNoticePage(@Validated NoticePageReqDTO pageReqVO) {
        return  noticeApi.getNoticePage(pageReqVO);
    }

    @GetMapping("/list")
    @Operation(summary = "获取通知公告普通列表")
    public CommonResult<List<NoticeRespDTO>> getNoticeList(@Validated NoticePageReqDTO pageReqVO) {
        return noticeApi.getNoticeList(pageReqVO);
    }

    @GetMapping("/get")
    @Operation(summary = "获得通知公告")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<NoticeRespDTO> getNotice(@RequestParam("id") Long id) {
        return noticeApi.getNotice(id);
    }
}
